<template>
  <div class="container-xl">
    <section class="new-good-course">
      <div class="container-xl goodcourse">
        <h2 class="content-title">
          <div class="content-title-left">
            <div class="hot">
              <div class="hot-left">HOT</div>
              <div class="hot-right"></div>
            </div>
            <div class="txt">
              <div class="txt-top">新上好课</div>
              <div class="txt-bottom"></div>
            </div>
          </div>
        </h2>
        <div class="course-content">
          <ul class="content-ul">
            <li class="content-li" v-for="item in containernew" :key="item.id">
              <div class="li-img">
                  <div class="li-img">
                    <a href="/course/detail/024f978cc56e405d9ecb2ed1db442495" title="echarts数据可视化入门+实战案例">
                        <img :src="item.courseCover" alt="echarts数据可视化入门+实战案例" title="echarts数据可视化入门+实战案例">
                    </a>
                  </div>
              </div>
              <div class="li-vip-img">
        
              </div>
              <div class="li-name">
                  <a href="/course/detail/024f978cc56e405d9ecb2ed1db442495" title="echarts数据可视化入门+实战案例">{{item.courseName}}</a>
              </div>
              <div class="li-desc">
                  <span></span>
                  {{courseType(item.courseLevel)}}
                  {{item.purchaseCounter}}
              </div>
              <div class="li-sale-price">
                  <div>
                    <span class="memberfree" v-if="item.isMember === 1">会员免费</span>
                    <span class="memberprice">￥{{item.discountPrice}}</span>
                  </div>
              </div>
            </li>
          </ul>
        </div>
      </div>
    </section>
  </div>
</template>

<script>
import { onBeforeMount, ref } from "vue";
import axios from 'axios';
import mixin from "@/mixin/mixin.js";

export default {
  name: "HelloCen",
  setup() {
    // 定义新上好课的数组变量
    let containernew = ref([]);
    let {courseType} = mixin();

    onBeforeMount(() => {
      axios
        .post("http://testapi.xuexiluxian.cn/api/course/mostNew", {
          pageNum: 1,
          pageSize: 10,
        })
        .then((res) => {
          containernew.value = res.data.data.pageInfo.list;
        });
        console.log(containernew)
    });
    return {
        containernew,
        courseType
    };
  },
};
</script>

<style scoped="css">
.container-xl {
  width: 1140px;
  height: 648px;
  overflow: hidden;
  margin: auto;
  padding: 0 0;
}

.goodcourse h2 {
  display: flex;
}

.content-title {
  display: flex;
  justify-content: space-between;
}

.content-title-left {
  display: flex;
}

.goodcourse h2 .hot {
  display: flex;
  height: 38px;
}

.goodcourse h2 .hot .hot-left {
  height: 38px;
  font-size: 20px;
  padding: 0 10px;
  text-align: center;
  line-height: 37px;
  color: #ffffff;
  border-radius: 8px 0 8px 8px;
  background: linear-gradient(90deg, #ff727f 0%, #fc685c 100%);
}

.goodcourse h2 .hot .hot-right {
  width: 0;
  height: 0;
  border: 6px solid #fc685c;
  border-right-color: transparent;
  border-bottom-color: transparent;
}

.goodcourse h2 .txt {
  position: relative;
  height: 38px;
  z-index: 50;
}

.goodcourse h2 .txt .txt-top {
  font-size: 24px;
  padding: 0 5px;
  color: #333333;
  line-height: 31px;
  font-weight: 700;
}

.goodcourse h2 .txt .txt-bottom {
  position: absolute;
  top: 25px;
  left: 0px;
  width: 100%;
  height: 13px;
  background: linear-gradient(90deg, #fbf84f 0%, #fea935 100%);
  border-radius: 7px;
  z-index: -1;
}

.course-content {
  width: 100%;
  height: 100%;
  /* background: red; */
  margin-top: 20px;
  display: flex;
}

.content-ul {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
}

ul,
li {
  list-style: none;
}

.content-li {
  position: relative;
  width: 270px;
  height: 275px;
  /* background: palevioletred; */
  margin-bottom: 20px;
  box-shadow: 1px 1px 10px rgb(27 39 94 / 40%);
  border-radius: 8px;
  transition: margin-top 0.2s;
  -webkit-transition: margin-top 0.2s;
  overflow: hidden;
}
.content-li:hover{
  margin-top: -15px;
}
ul,
li {
  list-style: none;
}

.content-li .li-img {
  width: 100%;
  height: 165px;
}

.li-vip-img {
  position: absolute;
  top: 5px;
  right: 10px;
}

.li-name {
  font-size: 16px;
  font-weight: 700;
  margin: 10px 10px 0 10px;
}

.li-desc {
  font-size: 12px;
  margin: 10px 0 0 10px;
}

.li-sale-price {
  position: relative;
  font-size: 14px;
  margin: 10px 0 0 10px;
  display: flex;
}

a {
    color: #333333;
    text-decoration: none;
}

.content-li .li-img img {
    width: 100%;
    height: 100%;
}

.memberfree {
    /* width: 80px; */
    padding: 2px 10px;
    height: 20px;
    color: #fff;
    font-size: 12px;
    background: linear-gradient(
90deg
,#ff928e,#fe7062 99%);
    border-radius: 24px 0 24px 0;
}

.memberprice {
    color: #fe7062;
    font-weight: bold;
    font-size: 16px;
}
</style>